package com.ruoyi.business.domain.enums;

public enum GenderEnum {
    FEMALE(2, "女"),
    MALE(1, "男");

    private final int key;
    private final String label;

    GenderEnum(int key, String label) {
        this.key = key;
        this.label = label;
    }

    public int getKey() {
        return key;
    }

    public String getLabel() {
        return label;
    }

    // 根据键值获取枚举实例
    public static GenderEnum fromKey(int key) {
        for (GenderEnum gender : GenderEnum.values()) {
            if (gender.getKey() == key) {
                return gender;
            }
        }
        throw new IllegalArgumentException("No enum constant for [" + key + "]");
    }
}